<?php
/**
 * 
 * IndexAction.class.php (前台首页)
 *
 * @package      	jgsat
 * @author          liuxun QQ:147613338 <admin@jgsat.cn>
 * @copyright     	Copyright (c) 2008-2011  (http://www.jgsat.com)
 * @license         http://www.jgsat.com/license.txt
 * @version        	jgsat企业网站管理系统 v2.1 2011-03-01 jgsat.cn $
 */
if(!defined("JGsat")) exit("Access Denied");
class AjaxAction extends BaseAction
{
    public function index()
    {

        $this->assign('bcid',0);//顶级栏目
        $this->assign('ishome','home');
        $this->display();
    }

    //推荐设计师
    public function designer(){
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);
        $of=$p*3;
        $list=M('User')->where('groupid=1 and status=1 and posid=1')->order('pos_time desc')->limit($of,3)->select();
        //echo M('Visa')->getLastSql();exit;
        foreach($list as &$v){
            $arr=M('Case')->field('id,pic')->where("userid=".$v['id']." and status=1")->limit('2')->select();
            $v['Case']=$arr;
            //擅长空间
            $itemType=explode(",",$v['itemType']);
          //  print_r($itemType);exit;
            $where="genre=17";
            if( $itemType[0]){$where.=" and id=".$itemType[0];}
            $arr=M('Label')->where($where)->find();
            $v['itemType']=$arr['title'];
            //价格
            $where_c="keyid=34";
            if( $v['charge']){$where_c.=" and typeid=".$v['charge'];}
            $charge=M('Type')->where($where_c)->find();
            $v['charge']=$charge['name'];
           //所在地
            $v['p']=jgarea($v['province']);
            $v['c']=jgarea($v['city']);
        }
        $p = $p + 1;
        //print_r($list);exit;
        if($list) {
            $data = array('list' => $list, 'p' => $p);
        }else{
            $data = array('list' => '1', 'p' => $p);
        }
        echo json_encode($data);//转换格式


    }

    //效果图
    public function Case2(){
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);
        $of=$p*4;
        $list=M('Case')->where('catid=2 and status=1 and posid=1')->order('pos_time desc')->limit($of,3)->select();
        $p = $p + 1;
        //print_r($list);exit;
        if($list) {
            $data = array('list' => $list, 'p' => $p);
        }else{
            $data = array('list' => '1', 'p' => $p);
        }
        echo json_encode($data);//转换格式

    }

//案例图
    public function Case1(){
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);
        $of=$p*4;
        $field='jg_case.id,jg_case.pic,jg_case.createtime,jg_case.title,jg_case.status,jg_case.posid,jg_case.describe,jg_user.id as userid,jg_user.avatar,jg_user.username as un,jg_user.my_introduce';
        $where='jg_case.`status`=1 and jg_case.catid=1 and jg_case.`posid`=1';
        $list=M('Case')->field($field)->where($where)->join('jg_user ON jg_case.userid = jg_user.id')->order("jg_case.pos_time desc")->limit($of,4)->select();
        $p = $p + 1;

        if($list) {
            $data = array('list' => $list, 'p' => $p);
        }else{
            $data = array('list' => '1', 'p' => $p);
        }
        echo json_encode($data);//转换格式

    }

    //推荐餐饮设备
    public function product(){
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);
        $of=$p*4;

        $list=M('Product')->where('status=1 and posid=1')->order("pos_time desc")->limit($of,4)->select();
        $p = $p + 1;
        //print_r($list);exit;
        if($list) {
            $data = array('list' => $list, 'p' => $p);
        }else{
            $data = array('list' => '1', 'p' => $p);
        }
        echo json_encode($data);//转换格式

    }


    //推荐餐饮设备
    public function news_c(){
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);
        $of=$p*3;

        $list=M("News")->where("posid=1 and lang=1 AND status=1  AND catid in(14,15,16,17,18,19)")->order("pos_time desc")->limit($of,3)->select();
        $p = $p + 1;
        //print_r($list);exit;
        foreach($list as &$v){
            $v['date']=date('m月d日 H:i:s',$v['createtime']);
            $v['description']=str_cut($v['description'],70);

        }
        if($list) {
            $data = array('list' => $list, 'p' => $p);
        }else{
            $data = array('list' => '1', 'p' => $p);
        }
        echo json_encode($data);//转换格式

    }

    public function news_x(){
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);
        $of=$p*3;

        $list=M("News")->where("posid=1 and lang=1 AND status=1  AND catid=8")->order("pos_time desc")->limit($of,3)->select();
        $p = $p + 1;
        //print_r($list);exit;
        foreach($list as &$v){
            $v['date']=date('m月d日 H:i:s',$v['createtime']);
            $v['description']=str_cut($v['description'],70);

        }
        if($list) {
            $data = array('list' => $list, 'p' => $p);
        }else{
            $data = array('list' => '1', 'p' => $p);
        }
        echo json_encode($data);//转换格式

    }



 
}
?>